<template>
    <div>
        <table>
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" v-model="querInfo.name"></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="querInfo.pwd"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="登录" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter();
import {useStore}from '@/stores/user';
const abc=useStore();

let querInfo: any = reactive({
    name: "",
    pwd: ""
})
const ok = () => {
    console.log(querInfo);
    axios({
        url: '/api/Admim/login',
        method: 'get',
        params: querInfo
    })
        .then((res) => {
            if (res.data == -1) {
                alert("用户名错误");
                return;
            } else if (res.data == -2) {
                alert("密码错误");
                return;
            }
            
                alert("登录成功");
                router.push("/patAdd");
                abc.user=res.data
                return;
           
        })
}

</script>

<style scoped></style>